Skip to content

fix(cli): wire praison run session continuity to project session store#1963

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-64d9
Draft

fix(cli): wire praison run session continuity to project session store#1963
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-64d9

Conversation

@cursor

@cursor cursor Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

praison run --continue/--session (#1929) discovered sessions in the project-scoped store (~/.praisonai/sessions/projects/...) but agents never loaded or saved there. auto_save alone did not set session_id or enable history, so:

  • Prior conversation context was silently dropped on resume
  • New messages were not persisted to the project store (silent data loss)
  • --output actions --session <id> crashed with TypeError from invalid resume_session Agent kwarg

Root cause

Session discovery used ProjectSessionStore, but agent persistence used get_default_session_store() with no session_id wired. handle_direct_prompt ignored args.resume_session, and praison.run() re-parsed CLI args, dropping session flags set by the run command.

Fix

  • Add build_cli_memory_config() and apply_cli_session_continuity() to wire agents to the project store
  • Apply in handle_direct_prompt, praison run actions mode, and YAML cli_config extraction
  • Preserve project session args across praison.run() arg re-parse
  • Respect caller-injected _session_store in _init_session_store()

Validation

  • Added unit tests in src/praisonai/tests/unit/cli/test_project_session_continuity.py
  • Verified history restore + save round-trip to project store
  • Verified actions mode Agent creation no longer raises TypeError
Open in WebΒ View AutomationΒ 

Summary by CodeRabbit

  • New Features

    • Enhanced CLI session continuity with improved memory and history restoration when resuming or forking sessions.
    • Optimized session store initialization for more reliable conversation history persistence.
  • Tests

    • Added comprehensive unit tests for session continuity and memory configuration handling.

The CLI session continuity feature (#1929) discovered sessions in the
project-scoped store but agents saved/loaded from the global default
store. auto_save alone did not set session_id or enable history, so
prior messages were never restored and new messages were silently lost.

- Add build_cli_memory_config() and apply_cli_session_continuity()
- Wire project store in handle_direct_prompt and praison run actions mode
- Preserve session args across praison.run() arg re-parse for YAML runs
- Respect caller-injected session store in _init_session_store()
- Fix --output actions crash from invalid resume_session Agent kwarg

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@MervinPraison

Copy link
Copy Markdown
Owner

@coderabbitai review

@MervinPraison

Copy link
Copy Markdown
Owner

/review

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more β†’

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account β†’

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us β†’

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
βœ… Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b82d8d7f-85c8-48f3-a1d9-20cf9de369dd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review
πŸ“ Walkthrough

Walkthrough

Two new helper functionsβ€”build_cli_memory_config and apply_cli_session_continuityβ€”are added to project_sessions.py to encapsulate project-scoped session wiring. These helpers are integrated into the CLI run command and handle_direct_prompt/main entrypoints. MemoryMixin._init_session_store is updated to skip overwriting an already-set session store.

Changes

CLI Project-Scoped Session Continuity

Layer / File(s) Summary
New session continuity helpers
src/praisonai/praisonai/cli/state/project_sessions.py
Adds build_cli_memory_config (returns MemoryConfig with history=True from session_id/auto_save inputs, or None) and apply_cli_session_continuity (wires agent to ProjectSessionStore, sets session/history attributes, restores prior chat_history).
Lazy session store init fix
src/praisonai-agents/praisonaiagents/agent/memory_mixin.py
_init_session_store now guards the get_default_session_store() call behind if self._session_store is None, preserving any previously injected store.
run.py: integrate helpers
src/praisonai/praisonai/cli/commands/run.py
Sets args.cli_project_sessions for YAML and non-actions paths; in actions mode, imports and calls build_cli_memory_config/apply_cli_session_continuity; removes prior inlined resume_session/auto_save wiring from agent_config.
main.py: flag preservation, memory injection, continuity
src/praisonai/praisonai/cli/main.py
Preserves auto_save, resume_session, and cli_project_sessions across parse_args; injects build_cli_memory_config result into YAML config and agent_config; calls apply_cli_session_continuity after direct-prompt agent construction.
Unit tests
src/praisonai/tests/unit/cli/test_project_session_continuity.py
Three tests covering build_cli_memory_config field correctness, history restoration via apply_cli_session_continuity, and preservation of an already-injected session store.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as run.py / main.py
  participant project_sessions as project_sessions.py
  participant ProjectSessionStore
  participant Agent as PraisonAgent

  User->>CLI: praisonai run --resume / --auto-save
  CLI->>project_sessions: build_cli_memory_config(session_id, auto_save)
  project_sessions-->>CLI: MemoryConfig(history=True, save_name=...)
  CLI->>Agent: PraisonAgent(**agent_config with memory)
  CLI->>project_sessions: apply_cli_session_continuity(agent, session_id)
  project_sessions->>ProjectSessionStore: get_project_session_store()
  project_sessions->>Agent: set _session_store, _session_id, _save_history
  project_sessions->>ProjectSessionStore: get_history(session_id)
  ProjectSessionStore-->>project_sessions: prior messages
  project_sessions->>Agent: agent.chat_history = prior messages
  Agent-->>User: response (with restored context)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • MervinPraison/PraisonAI#1929: Directly related β€” both PRs modify the CLI run command's session-continuity wiring (session resolve/resume, auto-save config), and this PR refactors/extends the session handling introduced in PR #1929 via the new build_cli_memory_config/apply_cli_session_continuity helpers.

Suggested labels

Review effort 3/5

Suggested reviewers

  • MervinPraison

πŸ‡ Hop, hop, hooray, sessions recall!
My history stays, not lost at all.
apply_cli_session_continuityβ€”
what a mouthful, but oh so free!
Old chats restored, the store won't lie,
lazy init fixed under the sky. 🌟

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title accurately describes the main change: wiring praison run session continuity to the project session store, which is the core bug fix across all modified files.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/critical-bug-investigation-64d9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MervinPraison

Copy link
Copy Markdown
Owner

@copilot Do a thorough review of this PR. Read ALL existing reviewer comments above from Qodo, Coderabbit, and Gemini first β€” incorporate their findings.

Review areas:

  1. Bloat check: Are changes minimal and focused? Any unnecessary code or scope creep?
  2. Security: Any hardcoded secrets, unsafe eval/exec, missing input validation?
  3. Performance: Any module-level heavy imports? Hot-path regressions?
  4. Tests: Are tests included? Do they cover the changes adequately?
  5. Backward compat: Any public API changes without deprecation?
  6. Code quality: DRY violations, naming conventions, error handling?
  7. Address reviewer feedback: If Qodo, Coderabbit, or Gemini flagged valid issues, include them in your review
  8. Suggest specific improvements with code examples where possible

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/praisonai/praisonai/cli/commands/run.py (1)

460-517: ⚠️ Potential issue | 🟠 Major | πŸ—οΈ Heavy lift

Profiled runs still bypass the new session-continuity flow.

Both profiled helpers accept continue_session, session, fork, and no_save, but neither path uses them when constructing PraisonAI/Agent. praison run --profile --continue/--session will therefore still behave differently from the normal path and miss the project-scoped restore/save wiring this PR is trying to standardize.

Also applies to: 519-578

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/praisonai/cli/commands/run.py` around lines 460 - 517, The
`_run_from_file_profiled` function (and similarly the profiled helper at lines
519-578) accepts session-continuity parameters `continue_session`, `session`,
`fork`, and `no_save` but does not pass them to the `PraisonAI` constructor. To
fix this, pass these parameters when constructing the `praison` object alongside
`agent_file` and `framework`, ensuring the profiled execution paths respect the
same session continuity logic as the non-profiled paths. Apply the same fix to
both profiled functions to maintain consistency across all execution modes.
🧹 Nitpick comments (3)
src/praisonai/tests/unit/cli/test_project_session_continuity.py (3)

1-58: πŸ’€ Low value

Consider adding edge case coverage.

The current tests focus on happy paths. To improve robustness, consider adding tests for:

  • build_cli_memory_config with None or empty session_id/auto_save
  • apply_cli_session_continuity with a nonexistent session (should it gracefully handle an empty history?)
  • Error scenarios like store I/O failures or invalid session data

This would increase confidence in error handling and boundary conditions.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/tests/unit/cli/test_project_session_continuity.py` around lines
1 - 58, Add new test functions to cover edge cases for the session continuity
features. Create test functions for: (1) `build_cli_memory_config` behavior with
None or empty values for session_id and auto_save parameters; (2)
`apply_cli_session_continuity` behavior when called with a nonexistent
session_id to ensure it gracefully handles empty chat history; (3) error
scenarios such as when the session store encounters I/O failures or receives
invalid session data. Each test should verify that the functions either handle
the edge case gracefully (returning expected defaults or empty states) or raise
appropriate exceptions with clear error messages.

52-52: πŸ’€ Low value

Consider reducing coupling to private implementation details.

Similar to the previous test, this accesses agent._session_store.session_dir and directly calls agent._init_session_store(). While this validates the internal lazy-init contract (per the PR fix), it couples the test to private methods. If the init mechanism changes, the test may break unnecessarily.

Document that this test intentionally validates the internal session store injection contract, or expose a public inspection API if broader testing needs exist.

Also applies to: 54-55

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/tests/unit/cli/test_project_session_continuity.py` at line 52,
The test accesses private implementation details like
agent._session_store.session_dir and agent._init_session_store() which creates
unnecessary coupling. Add a clear comment above the line accessing injected_dir
(line 52) and the subsequent lines (54-55) that documents the test's intent:
that it is intentionally validating the internal lazy-initialization contract of
the session store, explaining why direct access to these private members is
necessary for this specific validation. This makes the tight coupling explicit
and justified, clarifying to future maintainers that this is not casual private
API usage but rather a targeted contract test.

29-30: πŸ’€ Low value

Consider reducing coupling to private implementation details.

The test accesses private attributes (agent._session_store, agent._session_id) and calls a private method (agent._auto_save_session()). While acceptable for unit tests, this creates tight coupling to internal structure. If the Agent implementation changes (e.g., renames _session_id or changes auto-save mechanics), this test will break even if the public contract remains stable.

Consider whether public APIs exist for these checks (e.g., a get_session_id() method or a save() method), or document that this test intentionally validates internal wiring as part of the integration contract.

Also applies to: 36-36

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/tests/unit/cli/test_project_session_continuity.py` around lines
29 - 30, The test is tightly coupled to private implementation details like
agent._session_store, agent._session_id, and agent._auto_save_session(), which
will break if the internal implementation changes. Review whether public APIs
exist (such as a get_session_id() method or a save() method) that can be used
instead of accessing private attributes and methods. If public APIs exist,
refactor the assertions to use them. If no public APIs exist and these are
essential to validate, add a clear comment documenting that this test
intentionally validates internal wiring as part of the integration contract,
acknowledging the tight coupling.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/praisonai/praisonai/cli/commands/run.py`:
- Line 259: The cli_project_sessions assignment only checks auto_save_name, but
fails to account for session resumption via the --session/--continue flag. When
these options are combined with --no-save, session_id is still set but
auto_save_name becomes None, causing cli_project_sessions to incorrectly become
False and skip downstream project-store wiring for read-only resumes. Modify the
assignment of cli_project_sessions to include a check for the resume signal (the
session continuation flag) in addition to the auto_save_name check, so that
project sessions remain active when resuming even if saving is disabled. Apply
this same logic fix at all locations where cli_project_sessions is assigned
based on auto_save_name.

In `@src/praisonai/praisonai/cli/main.py`:
- Around line 4821-4825: The new session-continuity hook in
handle_direct_prompt() at the getattr(self.args, 'cli_project_sessions', False)
line unconditionally dereferences self.args without checking if it exists first.
Since the rest of handle_direct_prompt() uses hasattr(self, "args") guards to
protect against programmatic callers that invoke the method before parse_args()
completes, add the same guard pattern before the entire if block that checks for
cli_project_sessions and calls apply_cli_session_continuity. Wrap the session
continuity logic (lines checking cli_project_sessions and calling
apply_cli_session_continuity) inside a hasattr(self, "args") guard to prevent
AttributeError when self.args is unset.

In `@src/praisonai/praisonai/cli/state/project_sessions.py`:
- Around line 114-116: The build_cli_memory_config() function is incorrectly
re-enabling auto-save by using session_id as a fallback when auto_save is not
provided. The line save_name = auto_save or sid causes new turns to be persisted
even when the user explicitly requested no persistence with --no-save. Fix this
by only setting auto_save in the MemoryConfig when it was explicitly provided by
the user, not by falling back to the session_id. The same issue also appears in
apply_cli_session_continuity() at lines 126-127 where the agent configuration is
being set, so apply the same fix there to prevent re-enabling persistence in
resume-only runs.

---

Outside diff comments:
In `@src/praisonai/praisonai/cli/commands/run.py`:
- Around line 460-517: The `_run_from_file_profiled` function (and similarly the
profiled helper at lines 519-578) accepts session-continuity parameters
`continue_session`, `session`, `fork`, and `no_save` but does not pass them to
the `PraisonAI` constructor. To fix this, pass these parameters when
constructing the `praison` object alongside `agent_file` and `framework`,
ensuring the profiled execution paths respect the same session continuity logic
as the non-profiled paths. Apply the same fix to both profiled functions to
maintain consistency across all execution modes.

---

Nitpick comments:
In `@src/praisonai/tests/unit/cli/test_project_session_continuity.py`:
- Around line 1-58: Add new test functions to cover edge cases for the session
continuity features. Create test functions for: (1) `build_cli_memory_config`
behavior with None or empty values for session_id and auto_save parameters; (2)
`apply_cli_session_continuity` behavior when called with a nonexistent
session_id to ensure it gracefully handles empty chat history; (3) error
scenarios such as when the session store encounters I/O failures or receives
invalid session data. Each test should verify that the functions either handle
the edge case gracefully (returning expected defaults or empty states) or raise
appropriate exceptions with clear error messages.
- Line 52: The test accesses private implementation details like
agent._session_store.session_dir and agent._init_session_store() which creates
unnecessary coupling. Add a clear comment above the line accessing injected_dir
(line 52) and the subsequent lines (54-55) that documents the test's intent:
that it is intentionally validating the internal lazy-initialization contract of
the session store, explaining why direct access to these private members is
necessary for this specific validation. This makes the tight coupling explicit
and justified, clarifying to future maintainers that this is not casual private
API usage but rather a targeted contract test.
- Around line 29-30: The test is tightly coupled to private implementation
details like agent._session_store, agent._session_id, and
agent._auto_save_session(), which will break if the internal implementation
changes. Review whether public APIs exist (such as a get_session_id() method or
a save() method) that can be used instead of accessing private attributes and
methods. If public APIs exist, refactor the assertions to use them. If no public
APIs exist and these are essential to validate, add a clear comment documenting
that this test intentionally validates internal wiring as part of the
integration contract, acknowledging the tight coupling.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d8466d4-29af-41ca-a748-ae91c58ace31

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1ad58ca and e671898.

πŸ“’ Files selected for processing (5)
  • src/praisonai-agents/praisonaiagents/agent/memory_mixin.py
  • src/praisonai/praisonai/cli/commands/run.py
  • src/praisonai/praisonai/cli/main.py
  • src/praisonai/praisonai/cli/state/project_sessions.py
  • src/praisonai/tests/unit/cli/test_project_session_continuity.py

args = Args()
args.auto_save = auto_save_name
args.resume_session = session_id
args.cli_project_sessions = bool(auto_save_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

Use the resume signal when deciding whether project sessions are active.

These assignments only look at auto_save_name. When --session/--continue is combined with --no-save, session_id is still set but auto_save_name is None, so cli_project_sessions flips to False and the downstream main.py project-store wiring is skipped for read-only resumes.

Suggested fix
-            args.cli_project_sessions = bool(auto_save_name)
+            args.cli_project_sessions = bool(session_id or auto_save_name)
-        args.cli_project_sessions = bool(auto_save_name)
+        args.cli_project_sessions = bool(session_id or auto_save_name)

Also applies to: 416-416

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/praisonai/cli/commands/run.py` at line 259, The
cli_project_sessions assignment only checks auto_save_name, but fails to account
for session resumption via the --session/--continue flag. When these options are
combined with --no-save, session_id is still set but auto_save_name becomes
None, causing cli_project_sessions to incorrectly become False and skip
downstream project-store wiring for read-only resumes. Modify the assignment of
cli_project_sessions to include a check for the resume signal (the session
continuation flag) in addition to the auto_save_name check, so that project
sessions remain active when resuming even if saving is disabled. Apply this same
logic fix at all locations where cli_project_sessions is assigned based on
auto_save_name.

Comment thread src/praisonai/praisonai/cli/main.py Outdated
Comment on lines +4821 to +4825
if getattr(self.args, 'cli_project_sessions', False):
session_id = getattr(self.args, 'resume_session', None) or getattr(self.args, 'auto_save', None)
if session_id:
from .state.project_sessions import apply_cli_session_continuity
apply_cli_session_continuity(agent, session_id)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

Guard the new session-continuity hook when self.args is unset.

Line 4821 now dereferences self.args unconditionally inside handle_direct_prompt(). This method otherwise uses hasattr(self, "args") guards throughout, so programmatic callers that invoke it before main()/parse_args() will now crash with AttributeError right after agent construction.

Suggested fix
-            if getattr(self.args, 'cli_project_sessions', False):
-                session_id = getattr(self.args, 'resume_session', None) or getattr(self.args, 'auto_save', None)
+            if hasattr(self, 'args') and getattr(self.args, 'cli_project_sessions', False):
+                session_id = getattr(self.args, 'resume_session', None) or getattr(self.args, 'auto_save', None)
                 if session_id:
                     from .state.project_sessions import apply_cli_session_continuity
                     apply_cli_session_continuity(agent, session_id)
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/praisonai/cli/main.py` around lines 4821 - 4825, The new
session-continuity hook in handle_direct_prompt() at the getattr(self.args,
'cli_project_sessions', False) line unconditionally dereferences self.args
without checking if it exists first. Since the rest of handle_direct_prompt()
uses hasattr(self, "args") guards to protect against programmatic callers that
invoke the method before parse_args() completes, add the same guard pattern
before the entire if block that checks for cli_project_sessions and calls
apply_cli_session_continuity. Wrap the session continuity logic (lines checking
cli_project_sessions and calling apply_cli_session_continuity) inside a
hasattr(self, "args") guard to prevent AttributeError when self.args is unset.

Comment on lines +114 to +116
sid = session_id or auto_save
save_name = auto_save or sid
return MemoryConfig(session_id=sid, auto_save=save_name, history=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

Don't re-enable auto-save on resume-only runs.

build_cli_memory_config() currently turns session_id back into auto_save, and apply_cli_session_continuity() repeats that fallback on the agent. With --session/--continue --no-save, this will still write new turns into the session the user explicitly asked not to persist.

Suggested direction
 def build_cli_memory_config(
     session_id: Optional[str] = None,
     auto_save: Optional[str] = None,
 ):
@@
     from praisonaiagents import MemoryConfig

     sid = session_id or auto_save
-    save_name = auto_save or sid
-    return MemoryConfig(session_id=sid, auto_save=save_name, history=True)
+    return MemoryConfig(session_id=sid, auto_save=auto_save, history=True)

-def apply_cli_session_continuity(agent, session_id: str, project_path: Optional[str] = None) -> None:
+def apply_cli_session_continuity(
+    agent,
+    session_id: str,
+    project_path: Optional[str] = None,
+    auto_save: Optional[str] = None,
+) -> None:
@@
-    if not getattr(agent, "auto_save", None):
-        agent.auto_save = session_id
+    if auto_save is not None:
+        agent.auto_save = auto_save

Also applies to: 126-127

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/praisonai/cli/state/project_sessions.py` around lines 114 -
116, The build_cli_memory_config() function is incorrectly re-enabling auto-save
by using session_id as a fallback when auto_save is not provided. The line
save_name = auto_save or sid causes new turns to be persisted even when the user
explicitly requested no persistence with --no-save. Fix this by only setting
auto_save in the MemoryConfig when it was explicitly provided by the user, not
by falling back to the session_id. The same issue also appears in
apply_cli_session_continuity() at lines 126-127 where the agent configuration is
being set, so apply the same fix there to prevent re-enabling persistence in
resume-only runs.

@MervinPraison

Copy link
Copy Markdown
Owner

@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding.

Phase 1: Review per AGENTS.md

  1. Protocol-driven: check heavy implementations vs core SDK
  2. Backward compatible: ensure zero feature regressions
  3. Performance: no hot-path regressions

Phase 2: FIX Valid Issues
4. For any VALID bugs or architectural flaws found by Gemini, CodeRabbit, Qodo, Copilot, or any other reviewer: implement the fix
5. Push all code fixes directly to THIS branch (do NOT create a new PR)
6. Comment a summary of exact files modified and what you skipped

Phase 3: Final Verdict
7. If all issues are resolved, approve the PR / close the Issue
8. If blocking issues remain, request changes / leave clear action items

@praisonai-triage-agent

praisonai-triage-agent Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Claude finished @MervinPraison's task β€”β€” View job


Architecture Review & Bug Fix βœ…

Conducted final architecture review and successfully fixed all valid issues found by CodeRabbit, Qodo, and other reviewers.

Todo List:

  • Read AGENTS.md for architecture guidelines
  • Review changed files against protocol compliance
  • Fix cli_project_sessions logic bug (run.py:259, 416)
  • Fix missing args guard in main.py (line 4825)
  • Fix auto-save re-enabling bug in project_sessions.py (lines 114-116, 126-127)
  • Fix profiled runs bypassing session continuity (run.py:460-517, 519-578)
  • Test changes and validate fixes
  • Push fixes to branch
  • Provide final verdict

Architecture Compliance βœ…

The changes follow the protocol-driven design correctly:

  • Core SDK (praisonaiagents/): Only memory_mixin.py modified to fix lazy session store initialization
  • Wrapper (praisonai/): Heavy CLI session logic properly placed in wrapper package
  • Backward Compatibility: No breaking changes to public APIs
  • Performance: No hot-path regressions introduced

Fixed Issues:

βœ… Issue 1: Fixed cli_project_sessions to check both session_id and auto_save_name - now correctly enables project sessions for read-only resumes with --continue --no-save

βœ… Issue 2: Added hasattr(self, 'args') guard in main.py session continuity hook - prevents AttributeError when called programmatically

βœ… Issue 3: Removed automatic auto-save fallback in build_cli_memory_config and apply_cli_session_continuity - now respects --no-save flag properly

βœ… Issue 4: Added session continuity support to both profiled execution paths - ensures consistent behavior across all CLI modes

Changes Made:

  • src/praisonai/praisonai/cli/commands/run.py: Fixed project sessions logic and added session support to profiled functions
  • src/praisonai/praisonai/cli/main.py: Added args existence guard for session continuity
  • src/praisonai/praisonai/cli/state/project_sessions.py: Removed auto-save fallback, updated function signature

Final Verdict: βœ… APPROVED

All architectural and functional issues identified in the review have been resolved. The PR now:

  • βœ… Follows protocol-driven design principles
  • βœ… Maintains backward compatibility
  • βœ… Fixes the core session continuity bugs
  • βœ… Handles edge cases properly (--continue --no-save, profiled runs, programmatic usage)
  • βœ… Passes syntax validation and basic functionality tests

The PR is ready for merge.


πŸ”— Branch: cursor/critical-bug-investigation-64d9
πŸ“ Commit: 687d7269

- Fix cli_project_sessions logic to check both session_id and auto_save_name
- Add hasattr(self, 'args') guard in main.py session continuity hook
- Remove auto-save re-enabling fallback in project_sessions.py
- Add session continuity support to profiled execution paths

Fixes issues identified in PR review to ensure --no-save and --continue
work correctly together without silently re-enabling persistence.

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants